﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace SharpDiary.Core.Controls
{
    public class Line : Control
    {
        private Pen _pen = new Pen(Color.FromArgb(192, 192, 192), 1f);

        public Color LineColor
        {
            get
            {
                return _pen.Color;
            }
            set
            {
                _pen.Color = value;

                Invalidate();
            }
        }

        public Line()
        {
            DoubleBuffered = true;
            SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint, true);
            this.BackColor = Color.Transparent;

            _pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.DrawLine(_pen, new PointF(0, this.Height * 1f / 2f), new PointF(this.Width * 1f, this.Height * 1f / 2f));
        }
    }
}
